package com.css.common.core.constant;

import com.css.common.core.enums.TaxReturnEnum;
import com.css.common.core.enums.TaxReturnStatusEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

import static com.css.common.core.enums.TaxReturnEnum.*;

@Getter
@AllArgsConstructor
public enum FpkjztEnum {
    /**
     * 00：待开具，红票为非红冲阶段
     */
    FPKJZT_DKJ("待开具", 0),
    /**
     * 01：开具中
     */
    FPKJZT_KJZ("开具中", 1),
    /**
     * 02：开具成功
     */
    FPKJZT_KJCG("开具成功", 2),
    /**
     * 03：开具失败
     */
    FPKJZT_KJSB("开具失败", 3),

    /**
     * 开具异常
     */
    FPKJZT_KJ_EXCEPTION("开具异常", 4),

    /**
     * 查询异常
     */
    FPKJZT_CX_EXCEPTION("查询异常", 5),

    /**
     * 待缴税
     */
    FPKJZT_DJS("待缴税", 6),

    /**
     * 缴税中
     */
    FPKJZT_JSZ("缴税中", 7),

    /**
     * 缴税成功
     */
    FPKJZT_JS_SUCCESS("缴税成功", 8),

    /**
     * 缴税失败
     */
    FPKJZT_JS_FAIL("缴税失败", 9),

    /**
     * 缴税异常
     */
    FPKJZT_JS_EXCEPTION("缴税异常", 10),

    /**
     * 查询缴税异常
     */
    FPKJZT_JS_CX_FAIL("查询缴税信息失败", 11),

    /**
     * 缴税取消
     */
    FPKJZT_JS_CANCEL("缴税取消", 12),

    /**
     * 免缴税
     */
    FPKJZT_JS_FREE("免缴税", 13),

    /**
     * 待上传
     */
    FPKJZT_DSC("待上传", 14),

    /**
     * 待退税
     */
    FPKJZT_DTS("待退税", 15),

    /**
     * 退税成功
     */
    FPKJZT_TS_SUCCESS("退税成功", 16),

    /**
     * 退税失败
     */
    FPKJZT_TS_FAIL("退税失败", 17),

    /**
     * 退税异常
     */
    FPKJZT_TS_EXCEPTION("退税异常", 18),

    /**
     * 无需退税
     */
    FPKJZT_NOT_TS("无需退税", 19),

    /**
     * 退税中
     */
    FPKJZT_TS_PROCESSING("退税中", 20),

    /**
     * 手动开票
     */
    FPKJZT_SDKP("手动开票", 21),

    /**
     * 取消开票
     */
    FPKJZT_CANCEL("取消开票", 22),

    ;
    private final String mc;

    private final Integer type;

    public static FpkjztEnum getInstanceByKpjg(int kpjg) {
        switch (kpjg) {
            case AppCons.KP_RESULT_FAIL:
                return FPKJZT_KJSB;
            case AppCons.KP_RESULT_PROCESSING:
                return FPKJZT_KJZ;
            case AppCons.KP_RESULT_SUCCESS:
                return FPKJZT_KJCG;
            default:
                return FPKJZT_DKJ;
        }
    }

    public static FpkjztEnum getInstanceByHpjgzt(String hpjgzt) {
        switch (hpjgzt) {
            case "00":
                return FPKJZT_KJCG;
            case "-1":
            case "01":
                return FPKJZT_KJZ;
            default:
                return FPKJZT_KJSB;
        }
    }

    public static FpkjztEnum getInstance(Integer type) {
        FpkjztEnum[] values = values();
        for (FpkjztEnum value : values) {
            if (value.getType().equals(type)) {
                return value;
            }
        }
        return FPKJZT_KJSB;
    }

    /**
     * 转换退税
     *
     * @param taxReturnEnum 纳税申报枚举
     * @return {@link FpkjztEnum }
     */
    public static FpkjztEnum convertTaxReturn(TaxReturnEnum taxReturnEnum) {
        switch (taxReturnEnum) {
            case DTS:
                return FPKJZT_DTS;
            case WXTS:
                return FPKJZT_NOT_TS;
            case TSZ:
                return FPKJZT_TS_PROCESSING;
            case TSCG:
                return FPKJZT_TS_SUCCESS;
            case TSSB:
                return FPKJZT_TS_FAIL;
            default:
                return FPKJZT_TS_EXCEPTION;
        }
    }

    public static FpkjztEnum convertTaxReturnStatus(TaxReturnStatusEnum taxReturnStatusEnum) {
        switch (taxReturnStatusEnum) {
            case NOT_TAX:
                return FPKJZT_NOT_TS;
            case WAIT_TAX:
                return FPKJZT_DTS;
            case SUCCESS_TAX:
                return FPKJZT_TS_SUCCESS;
            case FAIL_TAX:
                return FPKJZT_TS_FAIL;
            default:
                return FPKJZT_TS_EXCEPTION;
        }
    }
}
